{	Problem: http://codeforces.ru/problemset/problem/14/A
 	Verdict: Accepted
}
var i,j,n,m,minx,maxx,miny,maxy:longint; a:array[0..51,0..51] of byte; c:char; f:boolean;
begin
fillchar(a,sizeof(a),0);
readln(n,m);
for i:=1 to n do begin
  for j:=1 to m do begin
    read(c);
    if c='.' then a[i][j]:=0 else a[i][j]:=1;
  end;
  readln;
end;
minx:=1;
maxx:=n;
miny:=1;
maxy:=m;
f:=false;
i:=0;
while (i<n) and (not f) do begin
  inc(i);
  j:=0;
  while (j<m) and (not f) do begin
    inc(j);
    if a[i][j]=1 then f:=true;
  end;
end;
minx:=i;
i:=n+1;
f:=false;
while (i>0) and (not f) do begin
  dec(i);
  j:=0;
  while (j<m) and (not f) do begin
    inc(j);
    if a[i][j]=1 then f:=true;
  end;
end;
maxx:=i;
j:=0;
f:=false;
while (j<m) and (not f) do begin
  inc(j);
  i:=0;
  while (i<n) and (not f) do begin
    inc(i);
    if a[i][j]=1 then f:=true;
  end;
end;
miny:=j;
j:=m+1;
f:=false;
while (j>0) and (not f) do begin
  dec(j);
  i:=0;
  while (i<n) and (not f) do begin
    inc(i);
    if a[i][j]=1 then f:=true;
  end;
end;
maxy:=j;
for i:=minx to maxx do begin
  for j:=miny to maxy do
    if a[i][j]=0 then write('.') else write('*');
  writeln;
end;
end.